package com.ssfGame.puremvc.view.application
{
	
	import com.ssfGame.puremvc.StaticConst;
	import com.ssfGame.puremvc.view.vc.ControlLayerVC;
	
	import flash.display.DisplayObject;
	
	import org.puremvc.as3.interfaces.INotification;
	import org.puremvc.as3.patterns.mediator.Mediator;
	
	/**
	 * 
	 * @author chery
	 */
	public class ControlLayerMediator extends Mediator
	{
		/**
		 * 
		 * @default 
		 */
		public static const NAME:String="ControlLayerMediator"
		/**
		 * 
		 * @param mediatorName
		 * @param viewComponent
		 */
		public function ControlLayerMediator(mediatorName:String=null, viewComponent:Object=null)
		{
			super(mediatorName, viewComponent);
		}
		override public function listNotificationInterests():Array{
			return [
				StaticConst.N_M_CONTROL_LAYER_ADD,
				StaticConst.N_M_CONTROL_LAYER_DEL
			]
		}
		override public function handleNotification(notification:INotification):void{
			var disObj:DisplayObject=notification.getBody() as DisplayObject
			switch(notification.getName()){
				case StaticConst.N_M_CONTROL_LAYER_ADD:
					if(!controlLayer.contains(disObj)){
						controlLayer.addChild(disObj)
					}
					break
				case StaticConst.N_M_CONTROL_LAYER_DEL:
					if(controlLayer.contains(disObj)){
						controlLayer.removeChild(disObj)
					}
					break
			}
		}
		private function get controlLayer():ControlLayerVC{
			return viewComponent as ControlLayerVC
		}
	}
}